package net.qunzhi.modules.historyspider;


import net.qunzhi.modules.cms.service.impl.TbFlowStateServiceImpl;
import net.qunzhi.modules.historyspider.client.URLHandle;
import org.apache.http.ParseException;
import org.apache.http.client.HttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

public class XjSpider {

    protected static Logger logger = LoggerFactory.getLogger(XjSpider.class);

    public static void start(String url, HttpClient client, Integer equipmentId, String maxtime, String pressureOrFlow) throws Exception {

        //String url = "http://127.0.0.1:8083/data/index.php?tagname=dtag000899";
        //List<EquipmentPressureState> jobsList = null;

        //开始解析
        try {
            System.out.println("开始响应客户端...");
            try {
//                Thread.sleep(200);
                //将客户端和url传过去先获取url解析接着来获取数据
                System.out.println(url+"equipmentId:"+equipmentId);
                URLHandle.urlParser(client, url, equipmentId, maxtime, pressureOrFlow);

            } catch (Exception e) {
                logger.error(e.getMessage());
                throw new Exception("网络异常");
            }
            //System.out.println("响应完成.");
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        //System.out.println("开始输出结果...");
        /*for (Xidata data:jobsList) {
           // System.out.println(data.toString());

        }*/

    }


}
